package com.luoluo.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.poi.POIDocument;
import org.apache.poi.POITextExtractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;

public class WordParser implements Parser {

	@Override
	public String parse(InputStream in) {

		try {
			WordExtractor extractor = new WordExtractor(in);
			return extractor.getText();
		} catch (IOException e) {
		}
		return null;
	}

	public static void main(String[] args) {
		WordParser parser = new WordParser();
		try {
			System.out.println(parser.parse(new FileInputStream(new File(
					"D:/j2cache.doc"))));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
